﻿@{
    ViewData["Title"] = "创建商品";
}
<div class="row">
    <div class="col-md-12">

        <div class="block-area" id="basic" ng-app="mainApp" ng-controller="mainCtrl">
            <h3 class="block-title">添加应用</h3>
            <div class="tile p-15">
                <form role="form">
                    <div class="form-group">
                        <label for="inputKey">应用编号</label>
                        <input type="text" ng-model="appinfo.id" required class="form-control input-sm" id="inputKey" placeholder="请填写应用标识">
                    </div>
                    <div class="form-group">
                        <label for="inputKey">应用标识</label>
                        <input type="text" ng-model="appinfo.appKey" required class="form-control input-sm" id="inputKey" placeholder="请填写应用标识">
                    </div>

                    <div class="form-group">
                        <label for="inputName">应用名称</label>
                        <input type="text" ng-model="appinfo.appName" required class="form-control input-sm" id="inputName" placeholder="请填写应用名称">
                    </div>

                    <button type="submit" ng-click="save()" class="btn btn-sm m-t-10">添加</button>
                    <button type="button" ng-click="reset()" class="btn btn-sm m-t-10">重置</button>
                </form>
            </div>
        </div>
    </div>
</div>
        @section scripts
{
            <script type="text/javascript">
                var app = angular.module('mainApp', []);
                app.controller('mainCtrl', function ($scope, $http) {
                    $scope.master = { appKey: "", appName: "" }
                    $scope.reset = function () {
                        $scope.appinfo = angular.copy($scope.master);
                    };
                    $scope.reset();
                    $scope.save = function () {
                        $http({
                            method: 'POST',
                            url: '@Url.Action("ProductSave", "Product")',
                            data: $scope.appinfo
                        }).success(function (data) { alert(data.Message) })
                          .error(function (data) { alert(data.Message) });
                    }
                });
            </script>
        }
